vscode: typography tokens for the Codev Markdown Preview (artifact canvas)#1071
Merged
Conversation
…line-height settings
…k-mode contrast
amrmelsayed
added a commit
that referenced
this pull request
Jun 18, 2026
Substantive ## section in UNRELEASED.md (token vocabulary expansion + host bindings + user settings + MarkdownView coverage + two dev-approval correctness fixes), single What's-new bullet in packages/vscode/CHANGELOG.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PIR Review: Typography tokens for the Codev Markdown Preview (artifact canvas)
Summary
The Codev Markdown Preview (
@cluesmith/codev-artifact-canvasmounted byMarkdownPreviewProvider)inherited the host's code-tuned typography: prose rendered at the workbench UI font with a tight
line-height and no paragraph rhythm, heading scale, or prose-element styling. Spec 945 D4 had
deliberately capped the v1
--codev-canvas-*vocabulary at colors, so there was no lever for anyof it.
This PR extends the canvas theming contract with a typography token tier (github-markdown-css
v5.8.1 as the pinned baseline) and wires it through the VSCode host, in three tiers:
default-theme.css) — 13 typography tokens (fontsize/family, line-height, paragraph spacing, optional prose-width cap, per-level heading sizes,
code font family/size) plus the CSS rules that consume them. The element pass also styled the
block elements that were falling through to user-agent defaults: inline
codechips, fencedpre, blockquotes, tables,hr, images, and list indentation.preview-template.ts) — binds code to the editor font while prose keeps thereadable sans stack, and pairs inline code with VSCode's theme-tuned
textPreformat-*tokens.package.json+preview-provider.ts) —codev.markdownPreview.fontSizeand
.lineHeight, with live reflow on change.Two color/layout correctness fixes landed during dev-approval review (see Lessons Learned): a
dark-mode inline-code contrast bug, and a page-level horizontal-scroll bug from unbreakable long
tokens.
The token vocabulary is a "locked public contract" (spec 945 D4), so the expansion carries a
spec-amendment doc trail across
types.ts, the package README, this review, and the issue.Architecture Updates
No changes needed to
arch.md/arch-critical.md. This PR extends an existing, documentedsubsystem (the spec-945 canvas theming contract) along the seam it was designed to extend — CSS
custom properties overridden by the host. It introduces no new module, process boundary, state
store, or invariant. The canvas's Model-A theming (CSS variables, not JS
resolve()) is unchanged;only the token vocabulary grew, which is documented in the package itself (
default-theme.css,README) and in the
types.tscontract comment, the correct homes for it.Lessons Learned Updates
No changes needed to the HOT
lessons-critical.md(it is capped and these are domain-specific, nothigh-blast-radius cross-cutting rules). Three reusable lessons are recorded in the COLD
lessons-learned.mdunder UI/UX (added in this PR):backgroundtoken without a matchingforegroundtoken is a latent contrast bug. Inlinecode shipped (pre-vscode: typography tokens for the Codev Markdown Preview (artifact canvas) #1053) with a background token but no foreground token, so its text fell through
to the general body foreground; the host then paired a code-block background with the general
foreground (different theme color groups, no contract that they contrast), and dark themes
rendered low-contrast inline code. Model surface fg/bg as a pair bound from the same theme
group; add the foreground in the same change as the background.
page-level horizontal scrollbar unless the prose container sets
overflow-wrap: break-word;pre/tablemust not wrap and opt out via their ownoverflow: autoto scroll within the block.em-on-emcompounding when nesting sized elements. Sizing bothpreandcodeto0.85emmade fencedpre code~72%; reset the innerpre codetofont-size: inherit(and itschip chrome) since code inside a fence is plain text, not an inline chip.
(All three recorded in
codev/resources/lessons-learned.mdunder UI/UX.)Files Changed
packages/artifact-canvas/src/styles/default-theme.csscode-foreground); prose/heading/code/blockquote/table/hr/img rules;overflow-wrapwrap fixpackages/artifact-canvas/src/types.tspackages/artifact-canvas/README.mdpackages/artifact-canvas/src/__tests__/default-theme.test.tspackages/vscode/src/markdown-preview/preview-template.tstextPreformat-*); Tier-3 user-override emissionpackages/vscode/src/markdown-preview/preview-provider.tscodev.markdownPreview.*; live reflow viaonDidChangeConfigurationpackages/vscode/package.jsoncodev.markdownPreview.fontSize/.lineHeightpackages/vscode/README.mdCommits
[PIR #1053] Add typography token tier to canvas default-theme.css[PIR #1053] Bind typography tokens in VSCode preview + add font-size/line-height settings[PIR #1053] Document markdownPreview font-size/line-height settings in README[PIR #1053] Add code-foreground token + style code/blockquote/table/hr/img elements[PIR #1053] Pair inline code with VSCode textPreformat tokens for dark-mode contrast[PIR #1053] Break long tokens in prose to prevent page-level horizontal scroll(Plus thread-log commits.)
Test Results
pnpm --filter @cluesmith/codev-artifact-canvas test— 55 passed (incl. the newdefault-theme.test.tstoken-vocabulary snapshot + contrast-token assertion).pnpm --filter codev-vscode test:unit— 442 passed.pnpm --filter @cluesmith/codev-artifact-canvas build, vscodecheck-types(host + webviewtsconfigs) and the esbuild production bundle — all clean.
code-foreground, andoverflow-wrapallland in the bundled
packages/vscode/dist/webview/markdown-preview.css.pane resize / no page-level horizontal scroll, per-block scroll on
pre/tables, and live reflowof the two settings.
Decisions Locked (at plan-approval, confirmed through dev-approval)
code-foreground, added during review) = 22 total.h1-size…h6-size), not scale+ratio:github-markdown-css's scale is non-geometric and a single ratio can't reproduce it.
the editor font. Baseline pinned to github-markdown-css v5.8.1.
prose-max-width— shipsnone(no cap); opt-in to e.g.72ch.Things to Look At
preview-template.ts): code tracks the editor font, prose uses thegithub sans stack. Documented inline so a future maintainer doesn't rebind prose to the editor
font (the cramped baseline this surface fixes).
pre+tablescroll withintheir block (long code lines / wide tables shouldn't wrap); prose breaks long tokens
(
overflow-wrap) so it never forces a page-level scrollbar.Follow-ups
The tokens and the two settings shipped here; vscode: in-preview typography controls (zoom) for the Codev Markdown Preview #1070 is purely the in-surface UI affordance,
deliberately out of this PR's scope.
How to Test Locally
afx dev pir-1053(or VSCode → right-click builder → Run Dev Server).codev/specs/945-build-foundational-reusable-pa.md).blocks are monospace + track the editor font; inline code is legible in both light and dark
themes; tables/blockquotes/hr render deliberately.
pre/tables scroll within their block.codev.markdownPreview.fontSize/.lineHeightin Settings — the open preview reflows.Fixes #1053